package com.example.gavin.scanfiles;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ScanFileActivity extends AppCompatActivity {

    // Used to load the 'native-lib' library on application startup.
    static {
        System.loadLibrary("native-lib");
    }

    private final String TAG = "ScanFileActivity";

    protected Button mBtnTest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scan_file);

        mBtnTest = (Button)findViewById(R.id.btn_test);
        mBtnTest.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "Click mBtnStartPreview");
                final String[] strArray={".apk",".mp3"};

                new Thread() {
                    public void run() {
                        initPath("/mnt/usb/sda1", strArray);
                        String[] fileList = getFileTypeList(".apk");
                        for (int i=0; i< fileList.length; i++){
                            Log.d(TAG, "file===" + fileList[i]);
                        }

                    }
                }.start();
            }
        });

    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    public native int initPath(String path, String args[]);

    public native String[] getFileTypeList(String fileType);
}
